/* $Id$ */
package org.crazydays.gameplan.map;


import org.junit.*;
import static org.junit.Assert.*;

/**
 * CoordinateUnitTest
 */
public class CoordinateUnitTest
{
    /**
     * Test constructor.
     */
    @Test
    public void testConstructor_0()
    {
        // test
        Coordinate coordinate = new Coordinate();

        // verify
        assertEquals("x", 0, coordinate.x);
        assertEquals("y", 0, coordinate.y);
    }

    /**
     * Test constructor.
     */
    @Test
    public void testConstructor_2()
    {
        // test
        Coordinate coordinate = new Coordinate(640, 480);

        // verify
        assertEquals("x", 640, coordinate.x);
        assertEquals("y", 480, coordinate.y);
    }

    /**
     * Test equals.
     */
    @Test
    public void testEquals()
    {
        Coordinate one = new Coordinate(10, 20);
        Coordinate two = new Coordinate(10, 20);

        assertTrue("equal", one.equals(two));
    }

    /**
     * Test equals.
     */
    @Test
    public void testEquals_not()
    {
        Coordinate one = new Coordinate(10, 20);
        Coordinate two = new Coordinate(20, 10);

        assertFalse("equal", one.equals(two));
    }

    /**
     * Test equals.
     */
    @Test
    public void testEquals_null()
    {
        Coordinate one = new Coordinate(10, 20);

        assertFalse("equal", one.equals(null));
    }

    /**
     * Test equals.
     */
    @Test
    public void testEquals_not_coord()
    {
        Coordinate one = new Coordinate(10, 20);

        assertFalse("equal", one.equals("string"));
    }

    /**
     * Test compareTo(Coordinate).
     */
    @Test
    public void testCompareTo_equals()
    {
        Coordinate one = new Coordinate(10, 20);
        Coordinate two = new Coordinate(10, 20);

        assertEquals("equals", 0, one.compareTo(two));
        assertEquals("equals", 0, two.compareTo(one));
    }

    /**
     * Test compareTo(Coordinate).
     */
    @Test
    public void testCompareTo_x()
    {
        Coordinate one = new Coordinate(10, 20);
        Coordinate two = new Coordinate(11, 20);

        assertEquals("x", -1, one.compareTo(two));
        assertEquals("x", 1, two.compareTo(one));
    }

    /**
     * Test compareTo(Coordinate).
     */
    @Test
    public void testCompareTo_y()
    {
        Coordinate one = new Coordinate(10, 20);
        Coordinate two = new Coordinate(10, 21);

        assertEquals("x", -1, one.compareTo(two));
        assertEquals("x", 1, two.compareTo(one));
    }
}
